package org.dromara.llm.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.llm.tts.TtsService;
import org.dromara.llm.tts.factory.TtsServiceFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


import java.io.IOException;

/**
 * 语言识别
 *
 * @author Miles Meng
 * @date 2025-06-25
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/llm/tts")
public class TtsController extends BaseController {
    private final TtsServiceFactory ttsServiceFactory;
    /**
     * 文本转语音
     *
     * @param text 文本
     * @return 语音文件路径
     */
    @SaIgnore
    @PostMapping("/textToSpeech")
    public R<String> textToSpeech(@RequestParam("text") String text) throws Exception {
        // 获取科大讯飞的TTS配置
        TtsService ttsService = ttsServiceFactory.getDefaultTtsService();
        String result = ttsService.textToSpeech(text);
        return R.ok(result);
    }


}
